package com.java110.mall.openapi.bmo.impl;

import com.alibaba.fastjson.JSONObject;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.intf.acct.IIntegralSettingV1InnerServiceSMO;
import com.java110.intf.acct.IIntegralV1InnerServiceSMO;
import com.java110.mall.openapi.bmo.IMallCommonApiBmo;
import com.java110.utils.util.Assert;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("computeIntegralMoneyBmoImpl")
public class ComputeIntegralMoneyBmoImpl implements IMallCommonApiBmo {

    @Autowired
    private IIntegralSettingV1InnerServiceSMO integralSettingV1InnerServiceSMOImpl;
    @Override
    public void validate(ICmdDataFlowContext context, JSONObject reqJson) {
        Assert.hasKeyAndValue(reqJson,"quantity","未包含积分数");
    }

    @Override
    public void doCmd(ICmdDataFlowContext context, JSONObject reqJson) {
        //todo 计算成金额
        double money = integralSettingV1InnerServiceSMOImpl.computeMoney(reqJson.getIntValue("quantity"));
        context.setResponseEntity(ResultVo.createResponseEntity(money));
    }
}
